#include "SQMircFuncs.h"

using namespace SqPlus;

_SQUIRRELDEF( CSQMircFuncs::Echo )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "echo", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Say )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "say", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Halt )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 1 )
	{
		CallFunc( "halt" );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Msg )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 3 )
	{
		const SQChar* szChannel = NULL;
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &szChannel );
		sq_getstring( v, 3, &sz );

		CallFunc( "msg", "%s %s", szChannel, sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Describe )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 3 )
	{
		const SQChar* szChannel = NULL;
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &szChannel );
		sq_getstring( v, 3, &sz );

		CallFunc( "describe", "%s %s", szChannel, sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::AMsg )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "amsg", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::AMe )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "ame", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Nick )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "nick", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::ANick )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "anick", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Join )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "join", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Part )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 2 )
	{
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &sz );

		CallFunc( "part", "%s", sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Kick )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 3 )
	{
		const SQChar* szChannel = NULL;
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &szChannel );
		sq_getstring( v, 3, &sz );

		CallFunc( "kick", "%s %s", szChannel, sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}

_SQUIRRELDEF( CSQMircFuncs::Ban )
{
	SQInteger iArgs = sq_gettop( v );

	if ( iArgs == 3 )
	{
		const SQChar* szChannel = NULL;
		const SQChar* sz = NULL;

		sq_getstring( v, 2, &szChannel );
		sq_getstring( v, 3, &sz );

		CallFunc( "ban", "%s %s", szChannel, sz );

		sq_pushbool( v, true );
		return 1;
	}

	sq_pushbool( v, true );
	return 1;
}